 function photoCode() {
    var photoCode = '';
    for (var i = 0; i < 3; i++) //3位随机数，用以加在时间戳后面。
    {
        photoCode += Math.floor(Math.random() * 10);
    }
    photoCode = new Date().getTime() + photoCode;  //时间戳，用来生成订单号。
    // console.log(photoCode)
    return photoCode;
  }

  
function orderCode() {
  var orderCode = '';
  for (var i = 0; i < 6; i++) //6位随机数，用以加在时间戳后面。
  {
    orderCode += Math.floor(Math.random() * 10);
  }
  orderCode = new Date().getTime() + orderCode;  //时间戳，用来生成订单号。
  // console.log(orderCode)
  return orderCode;
}

function currentTime() {
  var myDate = new Date();
  var f1 = "-";
  var f2 = ":";
  var month = myDate.getMonth() + 1;
  var date = myDate.getDate();
  var hour = myDate.getHours();
  var minute = myDate.getMinutes();
  var second = myDate.getSeconds();
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (date >= 0 && date <= 9) {
    date = "0" + date;
  }
  if (hour >= 0 && hour <= 9) {
    hour = "0" + hour;
  }
  if (minute >= 0 && minute <= 9) {
    minute = "0" + minute;
  }
  if (second >= 0 && second <= 9) {
    second = "0" + second;
  }
  var currentdate = myDate.getFullYear() + f1 + month + f1 + date + " " + hour + f2 + minute + f2 + second;
  return currentdate;
}
function judgeTime() {
  var myDate = new Date();
  var f1 = "-";
  var month = myDate.getMonth() + 1;
  var date = myDate.getDate();
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (date >= 0 && date <= 9) {
    date = "0" + date;
  }
  var currentdate = myDate.getFullYear() + f1 + month + f1 + date ;
  return currentdate;
}
  
module.exports = { photoCode,orderCode ,currentTime,judgeTime}